unit Notes;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Menus;

type
  RNoteData = record
    Left, Top, Width, Height: Integer;
    Color: Integer;
    NoteText: String;
  end;

  PNoteData = ^RNoteData;

  TNote = class(TForm)
    Caption: TPanel;
    AddBtn: TPanel;
    DeleteBtn: TPanel;
    NoteMemo: TMemo;
    AddPic: TImage;
    DeletePic: TImage;
    destructor Destroy; override;
    procedure CaptionMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    DragBegin: Boolean;
  public
    class procedure Add(AData: PNoteData; AOwner: TComponent; APopUpMenu: TPopUpMenu; BtnImages: TImageList);
  end;

var
  Note: TNote;

implementation

{$R *.dfm}

class procedure TNote.Add(AData: PNoteData; AOwner: TComponent; APopUpMenu: TPopUpMenu; BtnImages: TImageList);
begin
  with TNote.Create(AOwner) do
  begin
  NoteMemo.PopupMenu := APopUpMenu;
    if Assigned(AData) then
      begin
        Left := AData^.Left;
        Top  := AData^.Top;
        Width := AData^.Width;
        Height := AData^.Height;
        Color := AData^.Color;
      end;

    BtnImages.GetBitmap(0, AddPic.Picture.Bitmap);
    BtnImages.GetBitmap(1, DeletePic.Picture.Bitmap);

    Visible := True;
  end;
end;

procedure TNote.CaptionMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer); //Move form
begin
  ReleaseCapture;
  Perform(WM_SysCommand,$F012,0);
end;

destructor TNote.Destroy;
begin
  AddPic.Picture.Bitmap := nil;
  DeletePic.Picture.Bitmap := nil;
  NoteMemo.PopupMenu := nil;
  inherited;
end;

end.
